module(
    name = "nativelink",
    version = "0.7.8",
    compatibility_level = 0,
)

bazel_dep(name = "rules_cc", version = "0.1.5")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_python", version = "1.3.0")  # TODO(palfrey): Bump.
bazel_dep(name = "rules_shell", version = "0.4.1")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    configure_coverage_tool = True,
    python_version = "3.13",
)
use_repo(python, python = "python_versions")

bazel_dep(name = "rules_rust", version = "0.61.0")
archive_override(
    module_name = "rules_rust",
    integrity = "sha256-U8G6x+xI985IxMHGqgBvJ1Fa3SrrBXJZNyJObgDsfOo=",
    patch_strip = 1,
    patches = ["//tools:rules_rust-musl-platforms.diff"],
    urls = [
        "https://github.com/bazelbuild/rules_rust/releases/download/0.61.0/rules_rust-0.61.0.tar.gz",
    ],
)

crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
crate.from_cargo(
    name = "crates",
    cargo_lockfile = "//:Cargo.lock",
    manifests = [
        "//:Cargo.toml",
        "//nativelink-config:Cargo.toml",
        "//nativelink-error:Cargo.toml",
        "//nativelink-macro:Cargo.toml",
        "//nativelink-metric:Cargo.toml",
        "//nativelink-metric/nativelink-metric-macro-derive:Cargo.toml",
        "//nativelink-proto:Cargo.toml",
        "//nativelink-scheduler:Cargo.toml",
        "//nativelink-service:Cargo.toml",
        "//nativelink-store:Cargo.toml",
        "//nativelink-util:Cargo.toml",
        "//nativelink-worker:Cargo.toml",
    ],
    supported_platform_triples = [
        "aarch64-apple-darwin",
        "aarch64-unknown-linux-gnu",
        "aarch64-unknown-linux-musl",
        "arm-unknown-linux-gnueabi",
        "armv7-unknown-linux-gnueabi",
        "x86_64-apple-darwin",
        "x86_64-pc-windows-msvc",
        "x86_64-unknown-linux-gnu",
        "x86_64-unknown-linux-musl",
    ],
)
use_repo(crate, "crates")

# NativeLink uses Local Remote Execution for Rust by default which automatically
# handles Rust toolchain configuration via Nix.
#
# If you build outside of Nix you'll have to register these toolchains
# explicitly by passing `--extra_toolchains=@rust_toolchains//:all` to your
# Bazel invocation.
#
# WARNING: This configuration exists entirely as a convenience option and
#          migration and is not a supported way of building production
#          grade nativelink executables. It may be removed at any point in time.
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
    edition = "2024",

    # These should always follow the versions from LRE.
    rust_analyzer_version = "nightly/2025-05-21",
    rustfmt_version = "nightly/2025-05-21",
    sha256s = {
        "2025-05-21/cargo-nightly-x86_64-unknown-linux-gnu.tar.xz": "e866f249dfbdf10a68b7191c025257591e8a5aa2fede1663b34c88a4f4bb8a74",
        "2025-05-21/clippy-nightly-x86_64-unknown-linux-gnu.tar.xz": "0a312d722a94e3b9e1f7871d9a9af01d410917c2406dbf91d014c06fe79540fb",
        "2025-05-21/llvm-tools-nightly-x86_64-unknown-linux-gnu.tar.xz": "eee28e99ac24c27f3de969915e808c0645ee099b136e5547681110607d09d050",
        "2025-05-21/rust-std-nightly-x86_64-unknown-linux-gnu.tar.xz": "0985b6a8befea11c3f1465faac0adc8193a93512ede2fbe8afd3e6e84dd507e8",
        "2025-05-21/rustc-nightly-aarch64-apple-darwin.tar.xz": "f2c390199913eed60e2e0045afe96aa302e79977916deabc738dc39f2e16dc0d",
        "2025-05-21/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz": "ad97dbb43664f7dab1a32c4b22ee08ba40306e80972cb5583d7c16f2bf0a36df",
        "2025-05-21/rustfmt-nightly-aarch64-apple-darwin.tar.xz": "1409e65606d2db4ae6792ab9b075bf10986a0b6665dc54df575ce66a41efccdc",
        "2025-05-21/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz": "41ef09602146fe9ee9f2cdcea4341510551a80dcbdb55cb231b6b0e718a03eab",
        "cargo-1.87.0-aarch64-apple-darwin.tar.xz": "f8d6f554e5ed081de5c3fd23cf2f30f4012013e95fb7a5458a50d8215651fb88",
        "cargo-1.87.0-x86_64-unknown-linux-gnu.tar.xz": "469d5dc479835adadd728bc3587f8abf1941b3dd71f9865abd3e0783ae662555",
        "clippy-1.87.0-aarch64-apple-darwin.tar.xz": "eeadac2cc415890d952510bd32110da8ea14a710e997ae696212294b4401740f",
        "clippy-1.87.0-x86_64-unknown-linux-gnu.tar.xz": "9d440eef6811112a000acf96a062df7bcbc013fa4f8e00a7f9a4f57ef90637a1",
        "llvm-tools-1.87.0-aarch64-apple-darwin.tar.xz": "7efc6357a4422ca648ce027cc4c8bd7c36676bc38b1a82c17ccb2ad6dcd5d7a5",
        "llvm-tools-1.87.0-x86_64-unknown-linux-gnu.tar.xz": "872fdd4b3b8f6bcb01d20aae02cdd7848472386c9ba54c641d63ff82246ae935",
        "rust-std-1.87.0-aarch64-apple-darwin.tar.xz": "6547322b317f18b73695724ff60a7860457df1a646b4a79f89a70a13d0747375",
        "rust-std-1.87.0-x86_64-unknown-linux-gnu.tar.xz": "1b57253bd32b8b292c965b3a2d992a266763158494cab8555584c09360b90f77",
        "rustc-1.87.0-aarch64-apple-darwin.tar.xz": "175800bc89cccd8f8ee2f3a4d07bdf98c163030fd5d3dc6d5b23cf4dd0a2a4c3",
        "rustc-1.87.0-x86_64-unknown-linux-gnu.tar.xz": "e8395c5c5756253b76107055e093ffbc4431af7b30aeebe72ce2684b9cb53973",
    },
    versions = [
        "1.87.0",
        "nightly/2025-05-21",
    ],
)
use_repo(rust, "rust_toolchains")

bazel_dep(name = "toolchains_protoc", version = "0.4.3")

protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
protoc.toolchain(
    google_protobuf = "com_google_protobuf",
    version = "v30.2",
)

# Local remote execution.
bazel_dep(name = "local-remote-execution", version = "0.0.0")
local_path_override(
    module_name = "local-remote-execution",
    path = "local-remote-execution",
)
